package com.boot.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.boot.entity.Order;
import com.boot.mapper.OrderDao;
import com.boot.service.OrderService;
import com.boot.util.AdResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class OrderServiceImpl extends ServiceImpl<OrderDao, Order> implements OrderService {

	@Resource
	private OrderDao orderDao;
	
	@Override
	public AdResult saveOrder(Order order) {
		AdResult adResult=new AdResult();
		int affact_line=orderDao.saveOrder(order);
		if(affact_line>0){
			adResult.setMsg("保存成功");
			adResult.setStatus(1);
		}else{
			adResult.setMsg("保存失败");
			adResult.setStatus(0);
		}
		return adResult;
	}

	@Override
	public Order findOrder(String out_trade_no) {
		Order order=orderDao.findOrder(out_trade_no);
		if(order!=null){
			return order;
		}else{
			return null;
		}
	}

	@Override
	public boolean finishOrder(String out_trade_no) {
		int affect_line=orderDao.finishOrder(out_trade_no);
		if(affect_line>0){
			return true;
		}else{
			return false;
		}
	}

}
